//配置路由相关的信息
import Vue from "vue";
import VueRouter from "vue-router";

/// 这么写，结构清晰
Vue.use(VueRouter);

const Home = () => import("../views/home/Home.vue");
const Category = () => import('../views/category/Category.vue')
const Cart = () => import('../views/cart/Cart.vue')
const Profile = () => import('../views/profile/Profile.vue')

const routes = [
  {
    path: "",
    redirect: "home"  // 重定向
  },
  {
    path: "/home",
    component: Home,
  },
  {
    path: '/category',
    component: Category,
  },
  {
    path: '/cart',
    component: Cart,
  },
  {
    path: '/profile',
    component: Profile,
  }
];

const router = new VueRouter({
  //配置路由和组件之间的应用关系
  routes,         //这里一定要注意 ` routes `
  mode: 'history', //模式 1、hash(默认)  2、history
  // linkActiveClass: 'active' //统一配置所有 router-link 激活添加class样式。
});

export default router;